package com.baizhi.shane.shane.controller;

import com.baizhi.shane.common.base.Result;
import com.baizhi.shane.constant.ApiMapping;
import com.baizhi.shane.constant.SysMapping;
import com.baizhi.shane.constant.TableNameMapping;
import com.baizhi.shane.shane.dto.UserManagerOutDTO;
import com.baizhi.shane.shane.service.ShaneCollectQuestionService;
import com.baizhi.shane.shane.service.ShaneLikesQuestionService;
import com.baizhi.shane.shane.service.ShaneQuestionService;
import com.baizhi.shane.shane.vo.CountAndPageOutVO;
import com.baizhi.shane.shane.vo.PageInVO;
import com.baizhi.shane.shane.vo.PageQuestionOutVO;
import com.baizhi.shane.sys.service.SysUserService;
import com.baizhi.shane.sys.vo.IdVO;
import com.baizhi.shane.sys.vo.SuccessedOutVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 闻柏智
 * @date 2023/12/29 16:14:48
 */
@RestController
@RequestMapping(SysMapping.SHANE_ADMIN)
@Api(tags="后台管理")
public class ShaneAdminController {

    @Resource
    private ShaneQuestionService shaneQuestionService;
    @Resource
    private ShaneLikesQuestionService shaneLikesQuestionService;
    @Resource
    private ShaneCollectQuestionService shaneCollectQuestionService;
    @Resource
    private SysUserService sysUserService;


    /**
     *
     *
     * @Author 闻柏智
     * @Date 16:18 2023/12/29
     * @Param pageInVO
     * @return com.baizhi.shane.common.base.Result<com.baizhi.shane.shane.vo.PageQuestionOutVO>
     **/
    @ApiOperation(value="管理员测试", notes="管理员测试")
    @GetMapping(value = ApiMapping.ADMIN_TEST)
    public Result<PageQuestionOutVO> pageByContent() {

        return Result.OK("管理员测试");
    }

    /**
     * 用户管理信息列表查询
     *
     * @Author 闻柏智
     * @Date 17:37 2024/3/4
     * @Param pageInVO
     * @return com.baizhi.shane.common.base.Result<java.util.List<com.baizhi.shane.shane.dto.UserManagerOutDTO>>
     **/
    @ApiOperation(value="用户管理信息列表查询", notes="用户管理信息列表查询")
    @GetMapping(value = ApiMapping.USER_MANAGER_LIST)
    public Result<List<UserManagerOutDTO>> userManagerList(
            PageInVO pageInVO
    ) {
        List<UserManagerOutDTO> userManagerOutDTOIPage = shaneQuestionService.userManagerList(pageInVO);

        return Result.OK(userManagerOutDTOIPage);
    }

    /**
     * 用户管理信息列表数量查询
     *
     * @Author 闻柏智
     * @Date 17:37 2024/3/4
     * @Param pageInVO
     * @return com.baizhi.shane.common.base.Result<com.baizhi.shane.shane.vo.CountAndPageOutVO>
     **/
    @ApiOperation(value="用户管理信息列表数量查询", notes="用户管理信息列表数量查询")
    @GetMapping(value = ApiMapping.USER_MANAGER_COUNT_AND_PAGE_BY_CONTENT)
    public Result<CountAndPageOutVO> userManagerCountAndPageByContent(
            PageInVO pageInVO
    ) {
        CountAndPageOutVO countAndPageOutVO = shaneQuestionService.userManagerCountAndPageByContent(pageInVO);

        return Result.OK(countAndPageOutVO);
    }

    /**
     * 删除用户-通过ID
     *
     * @Author 闻柏智
     * @Date 17:54 2024/3/4
     * @Param idVO
     * @return com.baizhi.shane.common.base.Result<com.baizhi.shane.shane.vo.CountAndPageOutVO>
     **/
    @ApiOperation(value="删除用户-通过ID", notes="删除用户-通过ID")
    @PostMapping(value = ApiMapping.DELETE_ONE_USER_BY_ID)
    public Result<CountAndPageOutVO> deleteOneUserById(
            @RequestBody IdVO idVO
    ) {
        SuccessedOutVO successedOutVO = sysUserService.deleteOneUserById(idVO);

        return Result.OK(successedOutVO);
    }


}
